<html>
<head>
<script>

function testFunction()
{
    console.log("Begin");
    debugger; // Reload follows, nothing below should break.
    console.log("Middle: Breakpoint 1"); // Breakpoint
    console.log("Middle: Breakpoint 2"); // Breakpoint
    console.assert(false, "Assertion failed!");
    console.error("Some console.error message");
    debugger; // Should skip this also.
    var element = document.getElementById("element");
    var parent = element.parentElement;
    var child = document.createElement("span");
    element.setAttribute("foo", "bar"); // DOM breakpoint: AttributeModified
    element.appendChild(child);         // DOM breakpoint: SubtreeModified
    parent.removeChild(element);        // DOM breakpoint: NodeRemoved
    parent.appendChild(element);
    element.click(); // Event breakpoint
    console.log("End");
    // Should be last.
    eval("throwException()");
}

function throwException()
{
    function inner()
    {
        try {
            if (window.foo === 1)
                throw new Error("error message");
        } finally {
            ++window.foo;
        }
    }
    try {
        window.foo = 1;
        inner();
    } finally {
        ++window.foo;
    }
}

function scheduleTestFunction() {
  setTimeout(testFunction, 0);
}
</script>

</head>
<div id="element" onclick="return 0;"></div>
</body>
</html>
